package com.bbx.taxi.client.widget.Drag;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.bbx.taxi.client.R;
import com.bbx.taxi.client.Adapter.PayDetailsAdapter;
import com.bbx.taxi.client.Util.FormatUtil;

import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * Created by Flavien Laurent (flavienlaurent.com) on 23/08/13.
 */
public class DragLayout extends BaseDragLayout {
	private TextView tv_time;
	private TextView tv_order_type;
	private TextView tv_start;
	private TextView tv_end;
	private TextView tv_pay;
	private TextView tv_count;
	private ImageButton ib_kftel;
	/**hint支付类型*/
	private RelativeLayout layout_hint_paytype;
	private TextView tv_hint_paytype;
	private TextView tv_need_pay;
	/**支付的费用明细列表*/
	private ListView listview_paydetail;

	private PayDetailsAdapter mPayDetailsAdapter;
	/**支付费用明细列表*/
	private List<Map<String, String>> list_paydetail=new ArrayList<Map<String,String>>();
	public DragLayout(Context context) {
		super(context);
	}

	public DragLayout(Context context, AttributeSet attrs) {
		super(context, attrs, 0);
	}

	public DragLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public void initView() {
		setContentView(findViewById(R.id.desc));
		tv_time = (TextView) getContentView().findViewById(R.id.tv_time);
		tv_order_type = (TextView) getContentView().findViewById(R.id.tv_order_type);
		tv_start = (TextView) getContentView().findViewById(R.id.tv_start);
		tv_end = (TextView) getContentView().findViewById(R.id.tv_end);
		tv_pay = (TextView) getContentView().findViewById(R.id.tv_pay);
		tv_count = (TextView) getContentView().findViewById(R.id.tv_count);
		ib_kftel = (ImageButton) getContentView().findViewById(R.id.ib_kftel);
		tv_need_pay = (TextView) getContentView().findViewById(R.id.tv_need_pay);
		ib_kftel.setVisibility(View.GONE);
		layout_hint_paytype=(RelativeLayout)getContentView().findViewById(R.id.layout_hint_paytype);
		tv_hint_paytype=(TextView)getContentView().findViewById(R.id.tv_hint_paytype);
		listview_paydetail=(ListView) findViewById(R.id.lv_paydetail);
		mPayDetailsAdapter=new PayDetailsAdapter(context, list_paydetail);
		listview_paydetail.setAdapter(mPayDetailsAdapter);
	}
	/**
	 * 设置时间
	 */
	public void setTime(String text) {
		tv_time.setText(text);
	}

	/**
	 * 设置订单类型
	 */
	public void setOrderType(String text) {
		tv_order_type.setText(text);
	}

	/**
	 * 设置人数
	 */
	public void setCount(String text) {
		tv_count.setText(text);
	}

	public void setCountVisibility(int isVisibility) {
		tv_count.setVisibility(isVisibility);
	}

	/**
	 * 设置出发地
	 */
	public void setStart(String text) {
		tv_start.setText(text);
	}

	/**
	 * 设置目的地
	 */
	public void setEnd(String text) {
		tv_end.setText(text);
	}

	/**
	 * 设置支付多少钱
	 */
	public void setPay(double pay, boolean isPay,String paytype) {
		if (isPay) {
			tv_need_pay.setText(R.string.has_pay);
			layout_hint_paytype.setVisibility(View.VISIBLE);
			tv_hint_paytype.setText(paytype);
		}else{
			tv_need_pay.setText(R.string.need_pay);
			layout_hint_paytype.setVisibility(View.GONE);
		}
		tv_pay.setText(FormatUtil.onFormatDecimal(pay));
	}
    /**
     * 设置费用明细列表
     */
    public void setPayDetailList(List<Map<String, String>> list_paydetail){
    	this.list_paydetail.clear();
    	this.list_paydetail.addAll(list_paydetail);
    	mPayDetailsAdapter.notifyDataSetChanged();
    }

	@Override
	protected void onViewStatus(boolean isOpen) {
		// TODO Auto-generated method stub
		
	}
}
